﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace NIP.ControllerInterface
{
    public class Structs
    {
        #region error
        /// <summary>
        /// Struct definition for ErrorInfo
        /// </summary>
        [StructLayout(LayoutKind.Sequential, Pack = 0, CharSet = CharSet.Ansi)]
        public class ErrorInfo
        {
            public enum ErrorNumber
            {
                ERROR_NUMBER_ABSENT = -1
            } ;

            public enum AxisNumber
            {
                AXIS_NUMBER_ABSENT = -1
            } ;

            public ErrorInfo()
            {
                lNumber = (int)ErrorInfo.ErrorNumber.ERROR_NUMBER_ABSENT;
                cAxis = (sbyte)ErrorInfo.AxisNumber.AXIS_NUMBER_ABSENT;
                ulReserved1 = ulReserved2 = 0;
            }

            public Int32 lNumber;
            public sbyte cAxis;
            public UInt32 ulReserved1;
            public UInt32 ulReserved2;
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 81)]
            public char[] cOptional;
        }

        #endregion
        #region config
        /// <summary>
        /// Struct definition for ConfigData
        /// </summary>
        [StructLayout(LayoutKind.Sequential, Pack = 0, CharSet = CharSet.Ansi)]
        public class ConfigData
        {
            /// <summary>
            /// Operational mode for the USB-Controller box
            /// </summary>
            public short m_sMode;

            /// <summary>
            /// Axis types
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
            public short[] m_sType;

            /// <summary>
            /// USBC software version
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 24)]
            public char[] m_szUSBC_SoftVer;

            /// <summary>
            /// Robot type
            /// </summary>
            public short m_sContrType;

            /// <summary>
            /// Axis setup according groups
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
            public short[] m_sAxes;

            /// <summary>
            /// Size of points database
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
            public short[] m_sPoints;

            /// <summary>
            /// Number of axes
            /// </summary>
            public short m_sNumOfAxes;

            /// <summary>
            /// Gripper
            /// </summary>
            public short m_sGripper;

            /// <summary>
            /// Total number of inputs in the system
            /// </summary>
            public short m_sNumDIn;

            /// <summary>
            /// Total number of outputs in the system
            /// </summary>
            public short m_sNumDOut;

            /// <summary>
            /// Total number of analog inputs in the system
            /// </summary>
            public short m_sNumAIn;

            /// <summary>
            /// Total number of analog outputs in the system
            /// </summary>
            public short m_sNumAOut;

            /// <summary>
            /// mm
            /// </summary>
            public short m_sGripperRange;

            /// <summary>
            /// Current peripheral ID string
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
            public char[] m_szDeviceID1;

            /// <summary>
            /// Current peripheral ID string
            /// </summary>
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
            public char[] m_szDeviceID2;
        }
        #endregion
    }
}
